*08_results_longrun_figures.do
cap clear

global indir1 "/disk/bulkw/mrashid/matching_project/master_crosswalks"
global censdata "/homes/data/census-ipums/v2019/dta/"

global root    = "/disk/bulkw/nencka/schooling_pandemic/2021_10_18_final/"
global input   "$root/Input"
global scripts "$root/Scripts"
global temp    "$root/Temp"
global output  "$root/Output"
global log     "$root/Log"
global figures "$root/Figures/lr"

log using      "$log/08_results_longrun_figures", replace text

set scheme plotplain, perm 

cap log close 


*****************************************************************************
*****************************************************************************
*****************************************************************************

*Save graphs
cd "$figures/"

set obs 1
foreach x in educ_years incwage_40 incnonwg_40 annual_hours completed_gs completed_hs any_college completed_ba {
	gen `x'=.
}
list

label variable educ_years "Educational Attainment (Years)" 
label variable incwage_40 "Wage income (logged)" 
label variable incnonwg_40 "Non-wage income >= $50 (indicator)" 
label variable annual_hours "Annual hours worked (logged)" 
label variable completed_gs "Completed grade school" 
label variable completed_hs "Completed high school" 
label variable any_college "Any college" 
label variable completed_ba "Completed 4-year college" 


foreach var of varlist educ_years incwage_40 incnonwg_40 annual_hours  {

	local vtext : variable label `var'

*Create baseline and heterogeneity long-run graphs
preserve
	foreach x in longrun_regionbyr_ longrun_statebyr_ longrun_statec_ longrun_nozero_ longrun_regionbyr_mort_ longrun_laborl_ longrun_earlyw_ longrun_heterogeneous_focchigh_ longrun_heterogeneous_focclow_ longrun_heterogeneous_fbornfor_ longrun_heterogeneous_fbornus_ longrun_heterogeneous_black_ longrun_heterogeneous_nonblack_ {

		use "$temp/`x'`var'", clear
		keep if strpos(parm, "age_bin#c.weeks_closed_3wks") | strpos(parm, "1b.age_bin#co.weeks_closed_3wks")
		gen bucket = _n 
		lab def bucket_ts  1 "0-5"  2 "6-10"  3 "11-14" 4 "15-18" 5 "19-21" 6 "22-25" 
		lab values  bucket bucket_ts
		twoway rcap min95 max95 bucket, lstyle(ci) lcolor(gs8) legend(off) xtitle(Age in 1920) ysc(r(-0.2 0.2)) ylab(-0.2(0.05)0.2) yline(0, lpattern(dot) lcolor(black)) ytitle(`vtext') title("")  || scatter estimate bucket, mstyle(p1) connect(l) legend(off) xlabel(1 "0-5"  2 "6-10"  3 "11-14" 4 "15-18" 5 "19-21" 6 "22-25")

		graph export "$figures/`x'`var'.eps", replace 
}

*Create ihs long-run graphs

		use "$temp/longrun_ihs_`var'", clear
		keep if strpos(parm, "age_bin#c.ihs_days_closed") | strpos(parm, "1b.age_bin#co.ihs_days_closed")
		gen bucket = _n 
		lab def bucket_ts  1 "0-5"  2 "6-10"  3 "11-14" 4 "15-18" 5 "19-21" 6 "22-25" 
		lab values  bucket bucket_ts
		twoway rcap min95 max95 bucket, lstyle(ci) lcolor(gs8) legend(off) xtitle(Age in 1920) ysc(r(-0.2 0.2)) ylab(-0.2(0.05)0.2) yline(0, lpattern(dot) lcolor(black)) ytitle(`vtext') title("")  || scatter estimate bucket, mstyle(p1) connect(l) legend(off) xlabel(1 "0-5"  2 "6-10"  3 "11-14" 4 "15-18" 5 "19-21" 6 "22-25")

		graph export "$figures/longrun_ihs_`var'.eps", replace 
restore
}



*/
*Alternative education variables

foreach var of varlist completed_gs completed_hs any_college completed_ba  {

	local vtext : variable label `var'
preserve
	foreach x in longrun_regionbyr_  {


		use "$temp/`x'`var'", clear
		keep if strpos(parm, "age_bin#c.weeks_closed_3wks") | strpos(parm, "1b.age_bin#co.weeks_closed_3wks")
		gen bucket = _n 
		lab def bucket_ts  1 "0-5"  2 "6-10"  3 "11-14" 4 "15-18" 5 "19-21" 6 "22-25" 
		lab values  bucket bucket_ts
		twoway rcap min95 max95 bucket, lstyle(ci) lcolor(gs8) legend(off) xtitle(Age in 1920) ysc(r(-0.05 0.05)) ylab(-0.05(0.01)0.05) yline(0, lpattern(dot) lcolor(black)) ytitle(`vtext') title("")  || scatter estimate bucket, mstyle(p1) connect(l) legend(off) xlabel(1 "0-5"  2 "6-10"  3 "11-14" 4 "15-18" 5 "19-21" 6 "22-25")

		graph export "$figures/`x'`var'.eps", replace 

restore
		}
}


!mogrify -density 2000 -format png -- longrun*.eps


clear
capture log close

